/*
 * (C) Copyright 2006-2010 Nuxeo SAS (http://nuxeo.com/) and contributors.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser General Public License
 * (LGPL) version 2.1 which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/lgpl.html
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * Contributors:
 *     bstefanescu
 */
package org.nuxeo.gwt.habyt.invocation.client;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
 * 
 */
@SuppressWarnings("serial")
public class PropertyMap extends HashMap<String, Serializable> {

    public PropertyMap() {
    }

    public PropertyMap(int initialCapacity) {
        super(initialCapacity);
    }

    public PropertyMap(Map<String, Serializable> map) {
        super(map);
    }

    @SuppressWarnings("unchecked")
    public <T extends Serializable> T get(String key, T defaultValue) {
        T v = (T) get(key);
        return v == null ? defaultValue : v;
    }

    public String getString(String key) {
        return (String) get(key);
    }

    public String getString(String key, String defaultValue) {
        return get(key, defaultValue);
    }

    public Boolean getBoolean(String key) {
        return (Boolean) get(key);
    }

    public Boolean getBoolean(String key, Boolean defaultValue) {
        return get(key, defaultValue);
    }

    public Long getLong(String key) {
        return (Long) get(key);
    }

    public Long getLong(String key, Long defaultValue) {
        return get(key, defaultValue);
    }

    public Double getDouble(String key) {
        return (Double) get(key);
    }

    public Double getDouble(String key, Double defaultValue) {
        return get(key, defaultValue);
    }

    public Date getDate(String key) {
        return (Date) get(key);
    }

    public Date getDate(String key, Date defaultValue) {
        return get(key, defaultValue);
    }

}
